<template>
  <div v-if="showPage">
    <nuxt-child />
  </div>
</template>
<script>
// 所有需要进入项目就要执行的脚本，都写在这个文件里面
import { checkBrainLogin } from '@/api/account'

export default {
  data () {
    return {
      showPage: true
    }
  },
  beforeMount () {
    console.log('layout before mount this:', this)
    console.log('store:', this.$store.getters)
      
    const { role, account_id, token, oss_domain } = this.$store.getters
    if (!sessionStorage.getItem('token')) {
      sessionStorage.setItem('token', token)
    }
    if (!sessionStorage.getItem('account_id')) {
      sessionStorage.setItem('account_id', account_id)
    }
    if (!sessionStorage.getItem('role')) {
      sessionStorage.setItem('role', role)
    }
    if (!sessionStorage.getItem('oss_domain')) {
      sessionStorage.setItem('oss_domain', oss_domain)
    }
  },
  mounted () {
    // if (this.$route.query.app_id && this.$route.query.client_id && this.$route.query.ticket) {
    //   checkBrainLogin({
    //     app_id: this.$route.query.app_id,
    //     client_id: this.$route.query.client_id,
    //     ticket: this.$route.query.ticket,
    //   }).then(res => {
    //     console.log('res:', res)
    //     this.$store.commit('auth/SetToken', res.token)
    //     this.$store.commit('auth/SetRole', res.account.identity)
    //     this.$store.commit('auth/SetAccountId', res.account.id)
    //     sessionStorage.setItem('role', res.account.identity)
    //     sessionStorage.setItem('account_id', res.account.id)
    //     sessionStorage.setItem('token', res.token)
    //     this.showPage = true
    //   })
    // }
    // if (this.$route.query.token) {
    //   this.$store.commit('auth/SetToken', this.$route.query.token)
    //   sessionStorage.setItem('token', this.$route.query.token)
    // }
  },
  methods: {}
}
</script>